<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <link rel="stylesheet" th:href="@{/static/element/index.css}"/>
</head>
<body>
<div id="app">
    <template>

        <el-form :model="queryForm" ref="queryForm" :inline="true" label-width="100px">
            <el-form-item label="模块标题" prop="title">
                <el-input
                        v-model="queryForm.title"
                        placeholder="请输入模块标题"
                        clearable
                        size="small"
                        @keyup.enter.native="handleQuery"
                />
            </el-form-item>
<!--            <el-form-item label="业务类型" prop="businessType">-->
<!--                <el-select v-model="queryForm.businessType" placeholder="请选择业务类型" clearable-->
<!--                           size="small">-->
<!--                    <el-option-->
<!--                            v-for="dict in businessTypeOptions"-->
<!--                            :key="dict.dictValue"-->
<!--                            :label="dict.dictLabel"-->
<!--                            :value="dict.dictValue"-->
<!--                    />-->
<!--                </el-select>-->
<!--            </el-form-item>-->
            <el-form-item label="方法名称" prop="method">
                <el-input
                        v-model="queryForm.method"
                        placeholder="请输入方法名称"
                        clearable
                        size="small"
                        @keyup.enter.native="handleQuery"
                />
            </el-form-item>
            <el-form-item label="请求方式" prop="requestMethod">
                <el-input
                        v-model="queryForm.requestMethod"
                        placeholder="请输入请求方式"
                        clearable
                        size="small"
                        @keyup.enter.native="handleQuery"
                />
            </el-form-item>
<!--            <el-form-item label="操作类别" prop="operatorType">-->
<!--                <el-select v-model="queryForm.operatorType" placeholder="请选择操作类别" clearable-->
<!--                           size="small">-->
<!--                    <el-option-->
<!--                            v-for="dict in operatorTypeOptions"-->
<!--                            :key="dict.dictValue"-->
<!--                            :label="dict.dictLabel"-->
<!--                            :value="dict.dictValue"-->
<!--                    />-->
<!--                </el-select>-->
<!--            </el-form-item>-->
            <el-form-item label="操作人员" prop="operName">
                <el-input
                        v-model="queryForm.operName"
                        placeholder="请输入操作人员"
                        clearable
                        size="small"
                        @keyup.enter.native="handleQuery"
                />
            </el-form-item>

            <el-form-item label="请求URL" prop="operUrl">
                <el-input
                        v-model="queryForm.operUrl"
                        placeholder="请输入请求URL"
                        clearable
                        size="small"
                        @keyup.enter.native="handleQuery"
                />
            </el-form-item>
            <el-form-item label="主机地址" prop="operIp">
                <el-input
                        v-model="queryForm.operIp"
                        placeholder="请输入主机地址"
                        clearable
                        size="small"
                        @keyup.enter.native="handleQuery"
                />
            </el-form-item>

<!--            <el-form-item label="操作状态" prop="status">-->
<!--                <el-select v-model="queryForm.status" placeholder="请选择操作状态" clearable-->
<!--                           size="small">-->
<!--                    <el-option-->
<!--                            v-for="dict in statusOptions"-->
<!--                            :key="dict.dictValue"-->
<!--                            :label="dict.dictLabel"-->
<!--                            :value="dict.dictValue"-->
<!--                    />-->
<!--                </el-select>-->
<!--            </el-form-item>-->
            <el-form-item label="操作时间" prop="operTime">
                <el-date-picker clearable size="small" style="width: 200px"
                                v-model="queryForm.operTime"
                                type="date"
                                value-format="yyyy-MM-dd"
                                placeholder="选择操作时间">
                </el-date-picker>
            </el-form-item>

            <el-form-item>
                <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
                <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">清空</el-button>
            </el-form-item>
        </el-form>
        <el-row>
            <el-col :span="1.5">
                <el-button
                        type="primary"
                        icon="el-icon-plus"
                        size="mini"
                        @click="handleAddOrUpdate(1,null)"
                        v-if="button.add"
                >
                    新增
                </el-button>
            </el-col>
        </el-row>


        <el-table
                v-loading="loading"
                element-loading-text="加载中"
                element-loading-spinner="el-icon-loading"
                :data="tableData" row-key="id"
                :header-cell-style="{'text-align':'center','color':'#121212'}"
                :cell-style="{'text-align':'center'}" border style="margin-top: 10px"
        >
            <el-table-column label="编号" align="center" prop="id"></el-table-column>
            <el-table-column label="操作名称" align="center" prop="title"></el-table-column>
            <el-table-column label="方法名称" align="center" prop="method"show-overflow-tooltip="true"></el-table-column>
            <el-table-column label="请求方式" align="center" prop="requestMethod"></el-table-column>
            <el-table-column label="操作人员" align="center" prop="operName"></el-table-column>
            <el-table-column label="请求URL" align="center" prop="operUrl" show-overflow-tooltip="true"></el-table-column>
            <el-table-column label="主机地址" align="center" prop="operIp"></el-table-column>
            <el-table-column label="操作地点" align="center" prop="operLocation"></el-table-column>
            <el-table-column label="请求参数" align="center" prop="operParam" show-overflow-tooltip="true"></el-table-column>
            <el-table-column label="返回参数" align="center" prop="jsonResult" show-overflow-tooltip="true"></el-table-column>
            <el-table-column label="操作时间" align="center" prop="operTime" show-overflow-tooltip="true">
                <template slot-scope="scope">
                    <span>{{ scope.row.operTime}}</span>
                </template>
            </el-table-column>
            <el-table-column label="操作">
                <template slot-scope="scope">
                    <el-button  style="height: 0" type="text"
                               @click="handleAddOrUpdate(2,scope.row)">查看
                    </el-button>
                    <el-button v-if="button.delete" style="height: 0" type="text" @click="handleDelete(scope.row)">删除
                    </el-button>
                </template>
            </el-table-column>
        </el-table>
        <el-pagination
                background
                :page-sizes="[10, 20, 30, 40,50]"
                layout="total, sizes, prev, pager, next, jumper"
                :total="total"
                :page-size.sync="pageSize"
                :current-page.sync="currentPage"
                @size-change="handleQuery"
                @current-change="handleQuery"
                style="float: right;margin-top: 10px"
        />
    </template>
</div>
</body>
<script th:src="@{/static/js/axios.min.js}"></script>
<script th:src="@{/static/js/request.js}"></script>
<script th:src="@{/static/js/common.js}"></script>
<script th:src="@{/static/api/sysOperLog.js}"></script>
<script th:src="@{/static/js/vue.min.js}"></script>
<script th:src="@{/static/element/index.js}"></script>
<script th:src="@{/static/js/jquery.min.js}"></script>
<script th:src="@{/static/layer/layer.js}"></script>
<script>
    new Vue({
        el: '#app',
        data() {
            return {
                currentPage: 1,
                pageSize: 10,
                total: 0,
                tableData: [],
                button: {
                    add: false,
                    update: false,
                    delete: false
                },
                loading: false,
                queryForm: {
                    roleName: ''
                }
            }
        },
        created() {
            this.handleQuery();
            let sysButtons = JSON.parse(localStorage.getItem("mars-sysButtons"));
            this.button.add = sysButtons.indexOf("admin/sysOperLog/add") > -1;
            this.button.update = sysButtons.indexOf("admin/sysOperLog/update") > -1;
            this.button.delete = sysButtons.indexOf("admin/sysOperLog/delete") > -1;
        },
        methods: {
            resetQuery() {
                this.queryForm = {}
                this.handleQuery()
            },
            handleCurrentChange(val) {
                this.currentPage = val;
                this.handleQuery();
            },
            handleSizeChange(val) {
                this.pageSize = val;
                this.handleQuery();
            },
            handleQuery() {
                let queryParam = this.queryForm
                queryParam.pageNo = this.currentPage
                queryParam.pageSize = this.pageSize
                this.loading = true
                pageList(queryParam).then((res) => {
                    if (res.code === '200') {
                        this.tableData = res.data.list;
                        this.total = res.data.count;
                        this.loading = false
                    } else {
                        this.loading = false;
                        this.$notify({
                            title: '失败',
                            message: res.message,
                            type: 'error'
                        });
                    }
                });
            },
            handleDelete(row) {
                deleteById('/admin/sysOperLog/delete/' + row.id, this);
            },

            handleAddOrUpdate(type, row) {
                if (type === 1) {
                    openPage('新增操作日志记录', '/sysOperLog/sysOperLog-add-update.html', this);
                } else {
                    openPage('查看操作日志记录', '/sysOperLog/sysOperLog-add-update.html?id=' + row.id, this);
                }
            },
        }
    });
</script>
</html>
